﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace NoteHelper.Model
{
	public class Article
	{
		public Article()
		{
			ObjectID = 0;
			DateTime now = DateTime.Now;
			CreateTime = now;
			LastUpdateTime = now;
			FileUrl = "";
		    Description = "";
			Notes = new List<ArticleNote>();
			Attributes = new List<ArticleAttribute>();
		}

        [MinInt(0)]
		[DisplayName("文章ID")]
        public int ObjectID { get; set; }

		[DisplayName("创建时间")]
		public DateTime CreateTime { get; set; }

		[DisplayName("最后更新时间")]
		public DateTime LastUpdateTime { get; set; }

		[DisplayName("描述")]
        [StringLength(2000)]
        public string Description { get; set; }

		[DisplayName("文件路径")]
        [StringLength(500)]
        public string FileUrl { get; set; }
		
		[DisplayName("文章标签")]
		public virtual IList<ArticleAttribute> Attributes { get; set; }

		[DisplayName("读书笔记")]
		public virtual IList<ArticleNote> Notes { get; set; }

	    public override bool Equals(object obj)
	    {
	        var entity = obj as Article;
	        if (entity == null) return false;

	        if (entity.ObjectID != ObjectID || entity.Description != Description || entity.FileUrl != FileUrl)
	            return false;
	        return true;
	    }

	    public override int GetHashCode()
	    {
	        return base.GetHashCode();
	    }
	}
}
